Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use source map (if present) to translate source file references in backtrace. #278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

banburybill
Copy link

Establish framework for loading source maps if present and using them to translate references in a backtrace.

Implement this for Hermes. Use a regex to scan backtrace text and match source/line/col references. For sources where a source map is found, use the map to translate file/line/col references and substitute the translated reference into the backtrace text.

Should be easy to extend to DukTape given knowledge of DukTape backtrace formatting.

Fixes #277

Jim Hague added 4 commits July 15, 2021 10:03
…acktrace.

Pass the backtrace string through a lookup function that uses a regex to
extract the file path/line/col entries and replace them with ones
translated by a SourceMap.
@banburybill banburybill force-pushed the topic/hermes_backtrace_sourcemap branch from 255b6f9 to 9a446dd Compare August 16, 2021 14:54
@nick-thompson
Copy link
Collaborator

nick-thompson commented Aug 23, 2021

Hey @banburybill apologies for not getting to this for so long.

Looking over the change, I'm not actually sure that this is code we want to introduce, because I could imagine it being somewhat finicky to maintain (regex parsing source map strings across different js engines seems dicey). My intention would be more that the uncaught exception handlers there in the EcmascriptEngine implementations should be hit quite rarely. For example, I would personally aggressively recommend using something like React's error boundaries to try to find and catch errors in js land before they ever make it to the native uncaught error handler. That way we can rely on the existing source map support in the tools we're using without having to maintain something ourselves.

Have you tried using the error boundaries or similar for preventing uncaught errors in js?

Edit: perhaps I should add here too that my philosophy regarding this project structure is to write absolutely the minimum amount of native C++. Anything that we can do in javascript with reasonable performance should be preferred over adding new native code to the library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

If source map is present, use it to translate source file/line/column references in backtrace
2 participants